package tom.spring.cloud.feign.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * FeignClient内的服务名不区分大小写.
 * 注意：fallback生效必须配置启用feign.hystrix.enabled=true
 * @author ZHUFEIFEI
 */
@FeignClient(contextId = "helloService1", value = "provider01",path = "hello", fallback = HelloServiceFallback.class)
public interface HelloService {
	//注意不支持：GetMapping注解
    @RequestMapping("{name}")
    String hello(@PathVariable("name") String name);
}

@Component
class HelloServiceFallback implements HelloService {

    @Override
    public String hello(String name) {
        return "sorry, service unavailable.";
    }
}